import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '所属隐患',
    align: "center",
    dataIndex: 'dangerId_dictText'
  },
  {
    title: '所属任务',
    align: "center",
    dataIndex: 'taskId_dictText'
  },
  {
    title: '检查类型',
    align: "center",
    dataIndex: 'checkType_dictText'
  },
  {
    title: '检查项',
    align: "center",
    dataIndex: 'checkItemId_dictText'
  },
  {
    title: '检查项评分细则',
    align: "center",
    dataIndex: 'checkScoreId_dictText'
  },
  {
    title: '检查时间',
    align: "center",
    dataIndex: 'checkDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '罚款金额',
    align: "center",
    dataIndex: 'checkPay'
  },
  {
    title: '危害类型',
    align: "center",
    dataIndex: 'harmType_dictText'
  },
  // {
  //   title: '删除标识',
  //   align: "center",
  //   dataIndex: 'deleted_dictText'
  // },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "所属隐患",
    field: 'dangerId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_danger_investigation,danger_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "所属任务",
    field: 'taskId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_check_task,task_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "检查类型",
    field: 'checkType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "baseCheckType"
    },
    //colProps: {span: 6},
  },
  {
    label: "检查时间",
    field: "checkDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "危害类型",
    field: 'harmType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "harmType"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '所属隐患',
    field: 'dangerId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_danger_investigation,danger_name,id"
    },
  },
  {
    label: '所属任务',
    field: 'taskId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_check_task,task_name,id"
    },
  },
  {
    label: '检查类型',
    field: 'checkType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "baseCheckType"
    },
  },
  {
    label: '检查项',
    field: 'checkItemId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_check_item,check_content,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入检查项!'},
             ];
    },
  },
  {
    label: '检查项评分细则',
    field: 'checkScoreId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_check_score,deduct_illustrate,id"
    },
  },
  {
    label: '检查时间',
    field: 'checkDate',
    component: 'DatePicker',
  },
  {
    label: '罚款金额',
    field: 'checkPay',
    component: 'InputNumber',
  },
  {
    label: '危害类型',
    field: 'harmType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "harmType"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入危害类型!'},
             ];
    },
  },
  {
    label: '删除标识',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yn"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  dangerId: {title: '所属隐患',order: 0,view: 'list', type: 'string',dictTable: 'tb_base_danger_investigation', dictCode: 'id', dictText: 'danger_name',},
  taskId: {title: '所属任务',order: 1,view: 'list', type: 'string',dictTable: 'tb_base_check_task', dictCode: 'id', dictText: 'task_name',},
  checkType: {title: '检查类型',order: 2,view: 'list', type: 'string',dictCode: 'baseCheckType',},
  checkItemId: {title: '检查项',order: 3,view: 'list', type: 'string',dictTable: 'tb_base_check_item', dictCode: 'id', dictText: 'check_content',},
  checkScoreId: {title: '检查项评分细则',order: 4,view: 'list', type: 'string',dictTable: 'tb_base_check_score', dictCode: 'id', dictText: 'deduct_illustrate',},
  checkDate: {title: '检查时间',order: 5,view: 'date', type: 'string',},
  checkPay: {title: '罚款金额',order: 6,view: 'number', type: 'number',},
  harmType: {title: '危害类型',order: 7,view: 'list', type: 'string',dictCode: 'harmType',},
  deleted: {title: '删除标识',order: 8,view: 'radio', type: 'string',},
};
